home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / size / RCS / printMips.c,v < prev    next >
Encoding:
Text File  |  1990-02-16  |  4.3 KB  |  216 lines

  1. head     1.4;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.4
  10. date     90.02.16.13.47.18;  author rab;  state Exp;
  11. branches ;
  12. next     1.3;
  13.  
  14. 1.3
  15. date     89.07.26.23.45.40;  author rab;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     89.07.20.07.40.42;  author rab;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     89.07.19.17.16.25;  author rab;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 1.4
  35. log
  36. @*** empty log message ***
  37. @
  38. text
  39. @/* 
  40.  * sun23Print.c --
  41.  *
  42.  *    Contains the machine specific routine for printing the size if the
  43.  *    machine is a sun2 or sun3 (they both have the same a.out format).
  44.  *
  45.  * Copyright 1989 Regents of the University of California
  46.  * Permission to use, copy, modify, and distribute this
  47.  * software and its documentation for any purpose and without
  48.  * fee is hereby granted, provided that the above copyright
  49.  * notice appear in all copies.  The University of California
  50.  * makes no representations about the suitability of this
  51.  * software for any purpose.  It is provided "as is" without
  52.  * express or implied warranty.
  53.  */
  54.  
  55. #ifndef lint
  56. static char rcsid[] = "$Header: /a/newcmds/size/RCS/printMips.c,v 1.3 89/07/26 23:45:40 rab Exp Locker: rab $";
  57. #endif /* not lint */
  58.  
  59. #include <assert.h>
  60.  
  61. #ifndef mips
  62. #define mips 1
  63. #endif
  64.  
  65. #ifndef LANGUAGE_C
  66. #define LANGUAGE_C 1
  67. #endif
  68.  
  69. #ifndef MIPSEL
  70. #define MIPSEL
  71. #endif
  72.  
  73. #if 0
  74. #include <ds3100.md/aouthdr.h>
  75. #include <ds3100.md/filehdr.h>
  76. #include <ds3100.md/scnhdr.h>
  77. #include <ds3100.md/sys/exec.h>
  78. #include <ds3100.md/nlist.h>
  79. #endif
  80.  
  81. #include <ds3100.md/a.out.h>
  82. #include "size.h"
  83.  
  84.  
  85. /*
  86.  *----------------------------------------------------------------------
  87.  *
  88.  * PrintMips --
  89.  *
  90.  *    Prints out the size information for a decStation 3100
  91.  *
  92.  * Results:
  93.  *    SUCCESS if size information was printed, FAILURE otherwise.
  94.  *
  95.  * Side effects:
  96.  *    Stuff is printed.
  97.  *
  98.  *----------------------------------------------------------------------
  99.  */
  100.  
  101. ReturnStatus
  102. PrintMips(fp, printName, fileName, printHeadings, bufferSize, buffer)
  103.     FILE    *fp;        /* file that header was read from */
  104.     Boolean    printName;    /* TRUE => print name of file */
  105.     char    *fileName;    /* name of file */
  106.     Boolean    printHeadings;    /* TRUE => print column headings */
  107.     int        bufferSize;    /* size of buffer */
  108.     char    *buffer;    /* buffer containing header */
  109. {
  110.  
  111.     struct exec         *header;
  112.     struct aouthdr    *aoutheader;
  113.     char        swappedHeader[sizeof(*header) * 2];
  114.     int            swappedSize = sizeof(swappedHeader);
  115.     int            status;
  116.  
  117.     assert(HEADERSIZE >= sizeof(struct exec));
  118.     if (bufferSize < sizeof(struct exec)) {
  119.     return FAILURE;
  120.     }
  121.     header = (struct exec *) buffer;
  122.     aoutheader = &header->ex_o;
  123.     /*
  124.      * See if the magic number is ok.  If it is not, and the format
  125.      * is not mips format, then swap to little-endian and see if
  126.      * that fixes it.
  127.      */
  128.     if (N_BADMAG(*aoutheader) && (FMT_MIPS_FORMAT != hostFmt)) {
  129.     status = Fmt_Convert("{h2w3h2h2w13}", FMT_MIPS_FORMAT, &bufferSize,
  130.         buffer, hostFmt, &swappedSize, swappedHeader);
  131.     if (status) {
  132.         fprintf(stderr, "Fmt_Convert returned %d.\n", status);
  133.         return FAILURE;
  134.     }
  135.     header = (struct exec *) swappedHeader;
  136.     aoutheader = &header->ex_o;
  137.     if (N_BADMAG(*aoutheader)) {
  138.         return FAILURE;
  139.     }
  140.     }
  141.     if (printHeadings) {
  142.     printf("%-7s %-7s %-7s %-7s %-7s\n", 
  143.            "text", "data", "bss", "dec", "hex");
  144.     }
  145.     printf("%-7d %-7d %-7d %-7d %-7x",
  146.            header->a_text, header->a_data, header->a_bss,
  147.            header->a_text + header->a_data + header->a_bss,
  148.            header->a_text + header->a_data + header->a_bss);
  149.     if (printName) {
  150.     printf("\t%s\n", fileName);
  151.     } else {
  152.     printf("\n");
  153.     }
  154.     return SUCCESS;
  155. }
  156. @
  157.  
  158.  
  159. 1.3
  160. log
  161. @Added support for ds3100.
  162. @
  163. text
  164. @d18 1
  165. a18 1
  166. static char rcsid[] = "$Header: /a/newcmds/size/RCS/printMips.c,v 1.2 89/07/20 07:40:42 rab Exp Locker: rab $";
  167. d24 1
  168. a24 1
  169. #define mips
  170. d27 5
  171. a31 1
  172. #define LANGUAGE_C
  173. d33 1
  174. d35 4
  175. d40 3
  176. d73 2
  177. a74 1
  178.     struct exec        *header;
  179. d84 7
  180. a90 4
  181.     if (!N_BADMAG(*header)) {
  182.     goto doPrint;
  183.     }
  184.     if (FMT_MIPS_FORMAT != hostFmt) {
  185. d98 3
  186. a100 2
  187.     if (!N_BADMAG(*header)) {
  188.         goto doPrint;
  189. a102 2
  190.     return FAILURE;
  191. doPrint:
  192. @
  193.  
  194.  
  195. 1.2
  196. log
  197. @*** empty log message ***
  198. @
  199. text
  200. @d18 1
  201. a18 1
  202. static char rcsid[] = "$Header: /a/newcmds/size/RCS/printMips.c,v 1.1 89/07/19 17:16:25 rab Exp $";
  203. @
  204.  
  205.  
  206. 1.1
  207. log
  208. @Initial revision
  209. @
  210. text
  211. @d18 1
  212. a18 1
  213. static char rcsid[] = "$Header$";
  214. d71 3
  215. @
  216.